home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1999-2000 Id Software, Inc.
- //
- #include "ui_local.h"
-
- /*
- ===============================================================================
-
- CONNECTION SCREEN
-
- ===============================================================================
- */
-
- qboolean passwordNeeded = qtrue;
- menufield_s passwordField;
-
- static connstate_t lastConnState;
- static char lastLoadingText[MAX_INFO_VALUE];
-
- /*
- ========================
- UI_DrawConnectScreen
-
- This will also be overlaid on the cgame info screen during loading
- to prevent it from blinking away too rapidly on local or lan games.
- ========================
- */
- void UI_DrawConnectScreen( qboolean overlay ) {
- char *s;
- uiClientState_t cstate;
- char info[MAX_INFO_VALUE];
-
- Menu_Cache();
-
- if ( !overlay ) {
- // draw the dialog background
- UI_SetColor( color_white );
- UI_DrawHandlePic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, uis.menuBackShader );
- }
-
- // see what information we should display
- trap_GetClientState( &cstate );
-
- info[0] = '\0';
- if( trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ) ) {
- UI_DrawProportionalString( 320, 16, va( "Loading %s", Info_ValueForKey( info, "mapname" ) ), UI_BIGFONT|UI_CENTER|UI_DROPSHADOW, color_white );
- }
-
- UI_DrawProportionalString( 320, 64, va("Connecting to %s", cstate.servername), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
- UI_DrawProportionalString( 320, 96, "Press Esc to abort", UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
-
- // display global MOTD at bottom
- UI_DrawProportionalString( SCREEN_WIDTH/2, SCREEN_HEIGHT-32,
- Info_ValueForKey( cstate.updateInfoString, "motd" ), UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
-
- // print any server info (server full, bad version, etc)
- if ( cstate.connState < CA_CONNECTED ) {
- UI_DrawProportionalString( 320, 192, cstate.messageString, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, menu_text_color );
- }
-
- #if 0
- // display password field
- if ( passwordNeeded ) {
- s_ingame_menu.x = SCREEN_WIDTH * 0.50 - 128;
- s_ingame_menu.nitems = 0;
- s_ingame_menu.wrapAround = qtrue;
-
- passwordField.generic.type = MTYPE_FIELD;
- passwordField.generic.name = "Password:";
- passwordField.generic.callback = 0;
- passwordField.generic.x = 10;
- passwordField.generic.y = 180;
- Field_Clear( &passwordField.field );
- passwordField.width = 256;
- passwordField.field.widthInChars = 16;
- Q_strncpyz( passwordField.field.buffer, Cvar_VariableString("password"),
- sizeof(passwordField.field.buffer) );
-
- Menu_AddItem( &s_ingame_menu, ( void * ) &s_customize_player_action );
-
- MField_Draw( &passwordField );
- }
- #endif
-
- if ( lastConnState > cstate.connState ) {
- lastLoadingText[0] = '\0';
- }
- lastConnState = cstate.connState;
-
- switch ( cstate.connState ) {
- case CA_CONNECTING:
- s = va("Awaiting challenge...%i", cstate.connectPacketCount);
- break;
- case CA_CHALLENGING:
- s = va("Awaiting connection...%i", cstate.connectPacketCount);
- break;
- case CA_CONNECTED:
- s = "Awaiting gamestate...";
- break;
- case CA_LOADING:
- return;
- case CA_PRIMED:
- return;
- default:
- return;
- }
-
- UI_DrawProportionalString( 320, 128, s, UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, color_white );
-
-
- // password required / connection rejected information goes here
- }
-
-
- /*
- ===================
- UI_KeyConnect
- ===================
- */
- void UI_KeyConnect( int key ) {
- if ( key == K_ESCAPE ) {
- trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
- return;
- }
- }
-